/**
 * Created by lx on 2018/4/3.
 */
CommonUtils.regNamespace("com.im.projectInfoManage.carrayProjectManage");

$(function() {
    com.im.projectInfoManage.carrayProjectManage.invoke.init();
});

com.im.projectInfoManage.carrayProjectManage.invoke = function() {
    var client = new com.im.common.ajax();
    var tmpfiles;//文件上传下载
    var fileInfo = {};//存储附件信息
    var impleProjId;
    var freshFlag = false;
    var curSetRow;
    var rowTarget;
    var curIndex=-1;

    /**
     * 页面初始化
     * @private
     */
    function _init() {
        //初始化时间、复选框、下拉框等事件和样式
        _initCommpentAction();
        //表单验证
        _initFormValidate();
        //获取规划类型列表
        _queryPlanTypeList();
        //获取项目状态列表
        _queryPlanStateList();
        //注册项目列表查询事件
        $("#vQuerySubjectListBtn").on("click", function () {
            _querySubjectLis(1);
        }).trigger("click");
        //注册项目新增事件
        $("#vAddSubjectBtn").on("click", _showAddSubject);
        //注册新增修改项目事件
        $("#vAddEditSubjectBtn").on("click", _addEditSubject);
        //条件重置
        $("#vResetCond").on("click", _resetCond);
        //删除
        $('#removeProjectPlanBtn').click(function (){
            _deleteSubject();
        });
        //导出
        $('#exportProjectPlanBtn').click(function (){
            _exportList();
        });
        $('#projectSetModal').on('shown.bs.modal', function () {
            $("#setTable").empty();
            _showSetList();
        });
        //文件上传
        $('#fileBtn').click(function (){
            _initFile();
        });
        //新增阶段设置
//        $('#addImproStep').click(function (){
//        	$('#setTable').datagrid('insertRow',{
//                index : $('#setTable').datagrid('getRows').length,
//                row : {
//                	projStateName : 'test'
//                }
//            });
//        });

        $("#btnCloseSet").click(function () {
            if(freshFlag){
                //更新列表
                //_querySubjectLis(1); 刷新会导致序列变更，只能单独变更单元格的值
                freshFlag =  false;
            }
            $("#projectSetModal").modal("hide");
            _querySubjectLis(1);
        });

        // $("#vAddSubjectBbz").val("0.00");
        // $("#vAddSubjectScz").val("0.00");
        // $("#vAddSubjectGsslrz").val("0.00");
        // $("#vAddSubjectQyzc").val("0.00");
        // $("#vAddSubjectSzpt").val("0.00");
        // $("#vAddSubjectJj").val("");
        $(".money-control").blur(function () {
            _moneyInit(this,'blur')
        });
        $(".money-control").focus(function () {
            _moneyInit(this,'focus')
        });
    };

    function _initCommpentAction() {
        //时间插件
        $('#startDatepicker,#endDatepicker').datepicker({
            startView: 'decade',
            minView: 'decade',
            format: 'yyyy',
            maxViewMode: 2,
            minViewMode:2,
            autoclose: true
        });

        //复选框
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass   : 'iradio_minimal-blue'
        });

        //下拉框
        $('.select2').select2();

        //建设单位查询组件
        $("#vDevelopOrgInput2").unitselCommpent({
            elmIdSel : "vDevelopOrgInput2",//需要展示的位置下拉框
            unitType : "10",//单位类型 为空的时候全部查询
            callbackFunc: function (objvalue, objname) {//下拉框值改变时回调
                _querySubjectLis(1);
            }
        });

        //新增修改界面 所属规划、建设单位、规划工程组件
        $("#vPlanTypeSelect2").plan2unit2projectCommpent({
            elmIdProjectSel : "vAddProjectName",//规划工程下拉元素
            elmIdPlanTypeSel : "vPlanTypeSelect2",
            elmIdUnitSel : "vDevelopOrgNameInput2",//组织单位下拉元素
            //elmIdItemSel : "itemSel",//实施项目下拉元素
            orgType : "10",//初始化单位时，单位类型
            defaultContent : false ,
            callbackFunc: function (callBackType, ret) {//下拉框值改变时回调
                $('#addEditSubjectForm').data('bootstrapValidator').updateStatus('vDevelopOrgNameInput2', 'NOT_VALIDATED',null).validateField('vDevelopOrgNameInput2');
                $('#addEditSubjectForm').data('bootstrapValidator').updateStatus('vAddProjectName', 'NOT_VALIDATED',null).validateField('vAddProjectName');
                $('#addEditSubjectForm').data('bootstrapValidator').updateStatus('vPlanTypeSelect2', 'NOT_VALIDATED',null).validateField('vPlanTypeSelect2');
                if(callBackType == 2) {

                } else if(callBackType == 3) {
                    $("#vAddProjectName").attr("vaAddProjectId", ret.planProjId);
                } else if(callBackType == 1) {
                    $("#vPlanTypeSelect2").attr("vaPlanTypeId", ret.planProjClass);
                }
            }
        });

        //工程联系人查询组件
        $("body").append($($.parseHTML("<div class='modal fade bs-example-modal-lg' id='modal4' ></div>")));
        $("body").append($($.parseHTML("<div class='modal fade bs-example-modal-lg' id='modal5' ></div>")));
        $("#vQueryProjectUserBtn").click(function() {
            $("#vProjectUserInput").userSearchCommpent({
                elmIdOut : "vProjectUserInput",
                elmIdModal : "modal4",
                elmIdOrgModal : "modal5",
                callbackFunc: function (staffId, staffName, mobilePhone) {
                    $("#vProjectUserInput").attr("vaProjectUserId", staffId);
                    $("#vProjectUserNumberInput").val(mobilePhone);
                    $('#addEditSubjectForm').data('bootstrapValidator').updateStatus('vProjectUserInput', 'NOT_VALIDATED',null).validateField('vProjectUserInput');
//                    $('#addEditSubjectForm').data('bootstrapValidator').updateStatus('vProjectUserNumberInput', 'NOT_VALIDATED',null).validateField('vProjectUserNumberInput');
                }
            });
        });

        //工程负责人查询组件
        $("body").append($($.parseHTML("<div class='modal fade bs-example-modal-lg' id='modal7' ></div>")));
        $("body").append($($.parseHTML("<div class='modal fade bs-example-modal-lg' id='modal8' ></div>")));
        $("#vQueryProjectUserBtn2").click(function() {
            $("#vProjectUserInput2").userSearchCommpent({
                elmIdOut : "vProjectUserInput2",
                elmIdModal : "modal4",
                elmIdOrgModal : "modal5",
                callbackFunc: function (staffId, staffName) {
                    $("#vProjectUserInput2").attr("vaProjectUserId", staffId);
                    $('#addEditSubjectForm').data('bootstrapValidator').updateStatus('vProjectUserInput2', 'NOT_VALIDATED',null).validateField('vProjectUserInput2');
                }
            });
        });
    }

    /**
     * 表单验证
     * @param $form
     * @returns {boolean}
     * @private
     */
    function _formValidate($form) {
        $form.data("bootstrapValidator").validate();
        return $form.data("bootstrapValidator").isValid();
    }

    /**
     * 表单验证初始化
     * @private
     */
    function _initFormValidate(flag) {
        $("#addEditSubjectForm").bootstrapValidator({
            live: 'enabled',
            excluded: [':hidden'],
            feedbackIcons: {valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-loadData'},
            fields: {
                vAddSubjectName: {validators: {notEmpty: {message: "请填写项目名称"}}},
                vPlanTypeSelect2: {validators: {notEmpty: {message: "请选择所属规划"}}},
                vAddProjectName: {validators: {notEmpty: {message: "请填写规划工程"}}},
                vDevelopOrgNameInput2: {validators: {notEmpty: {message: "请选择建设单位"}}},
                startDatepicker: {trigger:"change",validators: {notEmpty: {message: "请选择开工年"}}},
                endDatepicker: {trigger:"change",validators: {
                    notEmpty: {message: "请选择完工年"},
                    callback: {message: "完工年不能小于开工年", callback:function(value, validator,$field){
                        if($("#startDatepicker").val() == null || $("#startDatepicker").val() == "" ||  $("#endDatepicker").val() == null||  $("#endDatepicker").val() == ""){
                            return true;
                        }
                        return new Date($("#startDatepicker").val()) <= new Date($("#endDatepicker").val());
                    }}
                }},
                vSubjectStateSelect: {validators: {notEmpty: {message: "请选择状态"}}},
                vProjectUserInput: {validators: {notEmpty: {message: "请选择工程联系人"}}},
//                vProjectUserNumberInput: {validators: {notEmpty: {message: "联系人电话不存在"}}},
                vProjectUserInput2: {validators: {notEmpty: {message: "请选择工程负责人"}}},
                vAddSubjectBbz: {validators: {notEmpty: {message: "请填写部补助金额"}, numeric: {message: '部补助只能输入数字'}
                    ,callback : {message: "小数点后精度不能多于2位", callback:function(value, validator,$field){
                        var tstr = value.split('.');
                        if(tstr.length > 1 && tstr[1].length > 2){
                            return false;
                        }
                        return true;
                    }}
                }},
                vAddSubjectScz: {validators: {notEmpty: {message: "请填写省财政金额"}, numeric: {message: '省财政只能输入数字'}
                    ,callback : {message: "小数点后精度不能多于2位", callback:function(value, validator,$field){
                        var tstr = value.split('.');
                        if(tstr.length > 1 && tstr[1].length > 2){
                            return false;
                        }
                        return true;
                    }}
                }},
                vAddSubjectGsslrz: {validators: {notEmpty: {message: "请填写政府融资金额"}, numeric: {message: '政府融资只能输入数字'}
                    ,callback : {message: "小数点后精度不能多于2位", callback:function(value, validator,$field){
                        var tstr = value.split('.');
                        if(tstr.length > 1 && tstr[1].length > 2){
                            return false;
                        }
                        return true;
                    }}
                }},
                vAddSubjectQyzc: {validators: {notEmpty: {message: "请填写部企业自筹金额"}, numeric: {message: '企业自筹只能输入数字'}
                    ,callback : {message: "小数点后精度不能多于2位", callback:function(value, validator,$field){
                        var tstr = value.split('.');
                        if(tstr.length > 1 && tstr[1].length > 2){
                            return false;
                        }
                        return true;
                    }}
                }},
                vAddSubjectSzpt: {validators: {notEmpty: {message: "请填写市州配套金额"}, numeric: {message: '市州配套只能输入数字'}
                    ,callback : {message: "小数点后精度不能多于2位", callback:function(value, validator,$field){
                        var tstr = value.split('.');
                        if(tstr.length > 1 && tstr[1].length > 2){
                            return false;
                        }
                        return true;
                    }}
                }}
                //, vAddSubjectJj: {validators: {notEmpty: {message: "请填写实施项目简介"}}}
            }
        });

        if(flag == undefined) {
            $('#addEditModal').on('hidden.bs.modal', function () {
                $('#addEditSubjectForm').data('bootstrapValidator').destroy();
                $('#addEditSubjectForm').data('bootstrapValidator', null);
                disableModalField(false);
                _initFormValidate("again");
            });
        }
    }

    /**
     * 获取规划类型列表
     * @private
     */
    function _queryPlanTypeList() {
        $("#vPlanTypeSelect").constantCommpent({
            elmIdSel : "vPlanTypeSelect",//需要展示的位置下拉框
            constParamCode : "PLAN_PROJ_CLASS",//需要加载的常量编码
            callbackFunc: function (objvalue, objname) {//下拉框值改变时回调
                _querySubjectLis(1);
            }
        });
    }

    /**
     * 获取项目状态列表
     * @private
     */
    function _queryPlanStateList() {
        var param = {};
        var planStateList = null;
        param.tabName = "T_PLAN_PROJECT";
        param.colName ="STATUS_CD";
        var result = client.callAsJson("commonService/queryTabColParam", param);
        if (result.success) {
            planStateList = result.result;
        } else {
            toastr.error(result.resultMsg);
            return;
        }

        //规划状态列表添加元素
        var subjectStateSelect = $("#vSubjectStateSelect");
        $.each(planStateList, function (i, item) {
            if(i == 0) {
                subjectStateSelect.append("<option value='" + item.colVal + "' selected='selected'>" + item.colValName + "</option>");
            } else {
                subjectStateSelect.append("<option value='" + item.colVal + "'>" + item.colValName + "</option>");
            }
        });
    }
    //合并单元格
    function mergeCellsByField(tableID, fldList,other) {
        var Arr = fldList.split(",");
        var dg = $('#' + tableID);
        var fldName;
        var RowCount = dg.datagrid("getRows").length;
        var span;
        var PerValue = "";
        var CurValue = "";
        var length = Arr.length - 1;
        for (i = length; i >= 0; i--) {
            fldName = Arr[i];
            PerValue = "";
            span = 1;
            for (row = 0; row <= RowCount; row++) {
                if (row == RowCount) {
                    CurValue = "";
                }
                else {
                    CurValue = dg.datagrid("getRows")[row][fldName];
                }
                if (PerValue === CurValue) {
                    span += 1;
                }
                else {
                    var index = row - span;
                    dg.datagrid('mergeCells', {
                        index: index,
                        field: fldName,
                        rowspan: span,
                        colspan: null
                    });
                    var name = other.split(",");
                    $.each(name,function (i,item){
                        dg.datagrid('mergeCells', {
                            index: index,
                            field: item,
                            rowspan: span,
                            colspan: null
                        });
                    });
                    span = 1;
                    PerValue = CurValue;
                }
            }
        }
    }

    /**
     * 获取规划列表
     * @param index 页索引
     * @param needTurn 是否需要页码
     * @private
     */
    function _querySubjectLis(index) {
        if(com.im.projectInfoManage.carrayProjectManage.subjectColumns == undefined) {
            com.im.projectInfoManage.carrayProjectManage.subjectColumns = [
                [{field:'全选',title:"全选",width:30,checkbox:true,rowspan:2,fitColumns:true},
                    {field:'vaSeq',title:"序<br/>号",width:30,rowspan:2,fitColumns:true,formatter: function(value,row,index){return row.seq;}},
                    {field:'planProjName',title:"工程名称",width:100,rowspan:2,fitColumns:true,align:'left'},
                    {field:'impleProjName',title:"实施项目名称",width:100,rowspan:2,fitColumns:true,align:'left', formatter: function(value,row,index){
                        if(row.subList && row.subList.length > 0) {
                            if(row.isExtend) {
                                return  "<a class='font_center' href='javascript:void(0)' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.showSSubject("+ index +");'><i class='fa fa-minus-square-o'></i> " +  value + "</a>";
                            } else {
                                return  "<a class='font_center' href='javascript:void(0)' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.showSSubject("+ index +");'><i class='fa fa-plus-square-o'></i> " +  value + "</a>";
                            }
                        } else {
                            return value;
                        }
                    }
                    },
                    {field:'developOrgName',title:"建设单位",width:80,rowspan:2,align:'left',fitColumns:true},
                    {title:"建设年限",colspan:2,fitColumns:true},
                    {field:'leadingPersonName',title:"项目<br/>负责人",rowspan:2,fitColumns:true},
                    {field:'linkmanName',title:"项目<br/>联系人",rowspan:2,fitColumns:true},
                    {title:"阶段资金构成（单位：万元）",colspan:6,fitColumns:true},
                    {field:'contentScale',title:"主要建设内容",rowspan:2,fitColumns:true,align:'left',formatter: function(value,row,index){
                        if(value){
                            if(value.length > 20){
                                return "<span style='cursor:pointer'><a  onclick='com.im.projectInfoManage.carrayProjectManage.invoke.showSubjectContent(\""+row.impleProjName+"\",\""+ value +"\");'>" + value.substr(0,20) + "...</a></span>";
                            }else{
                                return "<span style='cursor:pointer'><a onclick='com.im.projectInfoManage.carrayProjectManage.invoke.showSubjectContent(\""+row.impleProjName+"\",\""+ value +"\");'>"+ value + "</a></span>";
                            }
                        }
                    }},
                    {field:'projStageClassName',title:"当前阶段",width:100,rowspan:2,align:'left',fitColumns:true},
                    {field:'impleSituation',title:"进展描述",width:100,rowspan:2,align:'left',fitColumns:true,formatter: function(value,row,index){
                        if(value && value.length > 10){
                            return value.substr(0,10) + "...";
                        }else{
                            return value;
                        }
                    }},
                    {field:'preWorkSituation',title:"前期工作情况",width:140,rowspan:2,align:'left',fitColumns:true,formatter: function(value,row,index){
                        if(value) {
                            return value.replace(/;/g,'<br/>');
                        } else {
                            return "";
                        }
                    }},
                    {field:'statusName',title:"状态",width:40,rowspan:2,fitColumns:true},
                    {field:'vaOperation',title:"操<br/>作",width:40,rowspan:2,fitColumns:true,formatter: function(value,row,index){
                        if(row.planProjName){
                            if(row.parentImpleProjId == null || row.parentImpleProjId == "") {
                                return  "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.showEditSubject("+ index +");' title='修改'><i class='fa fa-edit'></i></a>"+
                                    "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.setSubject("+index+",this);' title='设置'><i class='fa fa-cog'></i></a>";
                            } else {
                                return  "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.showEditSubject("+ index +");' title='修改'><i class='fa fa-edit'></i></a> "+
                                    "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.setSubject("+index+",this);' title='设置'><i class='fa fa-cog'></i></a>";
                            }
                        }
                    }}],
                [{field:'startDt',title:"开工年",fitColumns:true},
                    {field:'endDt',title:"完工年",fitColumns:true},
                    {field:'total',title:"合计",fitColumns:true},
                    {field:'fundSourceBu',title:"部补助",fitColumns:true},
                    {field:'fundSourceSheng',title:"省财政",fitColumns:true},
                    {field:'fundSourceGao',title:"政府融资",fitColumns:true},
                    {field:'fundSourceShi',title:"市州配套",fitColumns:true},
                    {field:'fundSourceQi',title:"企业自筹",fitColumns:true}]
            ];
        }

        var req = {};
        req.pageInfo = {};
        req.pageInfo.pageNumber = index;
        req.pageInfo.pageSize = 20;
        req.impleProjName = $("#vSubjectNameInput").val();
        req.planProjName = $("#vProjectNameInput").val();
        req.planProjClass = $("#vPlanTypeSelect option:selected").attr("value");
        req.developOrg = $("#vDevelopOrgInput2 option:selected").attr("value");
        var resp = client.callAsJson("projectInfoService/queryImpleProjList", req);
        if (!resp.success) {
            toastr.error(resp.resultMsg);
            return;
        }

        $.each(resp.result.rows, function(i,item){
            item.seq = i + 1;
        });


        $("#vSubjectTable").empty();
        $("#vSubjectTable").datagrid({
            pagination:true,
            showFooter: true,
            nowrap:false,
            fitColumns:true,
            columns:com.im.projectInfoManage.carrayProjectManage.subjectColumns,
            data:resp.result,
            onLoadSuccess: function (data) {
                if (data.rows.length > 0) {
                    mergeCellsByField('vSubjectTable', "planProjName",'');
                }
            }
        });
        var p = $('#vSubjectTable').datagrid('getPager');
        $(p).pagination({
            total : resp.result.total,
            pageSize : resp.result.pageSize,
            pageNumber : resp.result.pageNumber,
            pageList : [20 , 40],
            beforePageText: '第',
            afterPageText: '页    共 {pages}  页',
            displayMsg: '当前显示 {from} - {to} 条记录 共 {total}  条记录',
            onSelectPage:function(pageNumber, pageSize){
                _querySubjectLis(pageNumber, false);
            }
        });
    }

    /**
     * 展开子项目
     * @param index
     * @private
     */
    function _showSSubject(index) {
        var row = $('#vSubjectTable').datagrid('getData').rows[index];
        row.isExtend = !row.isExtend;
        $('#vSubjectTable').datagrid('refreshRow', index);

        if(row.isExtend) {
            $.each(row.subList, function(i,item){
                item.seq = row.seq + "-" + (i + 1);
                $("#vSubjectTable").datagrid('insertRow',{
                    index : index + i + 1,
                    row : item
                })
            });
        } else {
            var datas = $('#vSubjectTable').datagrid('getData');
            for(var i = 0; i < datas.rows.length; i++){
                for(var j = 0; j < row.subList.length; j++) {
                    if(datas.rows[i].seq == row.subList[j].seq) {
                        var rowIndex = $('#vSubjectTable').datagrid('getRowIndex',datas.rows[i]);
                        $('#vSubjectTable').datagrid('deleteRow', rowIndex);
                    }
                }
            }
        }
    }

    /**
     * 新增项目
     * @private
     */
    function _showAddSubject() {
        $('#addEditModal .modal-title').html('项目新增');
        $("#vAddSubjectName").val("");
        $("#vAddSubjectName").attr("vaAddSubjectId", "");
//        $("#vAddParentSubjectName").val("");
//        $("#vAddParentSubjectName").attr("vaParentSubjectId", "");
        // $("#vPlanTypeSelect2").find("option:selected").removeAttr("selected");
        // $("#vPlanTypeSelect2").find("option").first().attr("selected", "selected");
        // $("#vPlanTypeSelect2").trigger("change");
        $("#vPlanTypeSelect2").val($("#vPlanTypeSelect").val()).trigger("change");
        $("#vAddProjectName").val("");
        $("#vAddProjectName").attr("vaAddProjectId", "");
//        $("#vDevelopOrgNameInput2").val("");
//        $("#vDevelopOrgNameInput2").attr("vaDevelopOrgId", "");
        // $("#vDevelopOrgNameInput2").find("option:selected").removeAttr("selected");
        // $("#vDevelopOrgNameInput2").find("option").first().attr("selected", "selected");
        // $("#vDevelopOrgNameInput2").trigger("change");
        $("#vDevelopOrgNameInput2").val($("#vDevelopOrgInput2").val()).trigger("change");
        $("#startDatepicker").val("");
        $("#endDatepicker").val("");
        $("#vSubjectStateSelect").find("option:selected").removeAttr("selected");
        $("#vSubjectStateSelect").find("option").first().attr("selected", "selected");
        $("#vSubjectStateSelect").trigger("change");
        $("#vProjectUserInput2").val("");
        $("#vProjectUserInput2").attr("vaProjectUserId", "");
        $("#vProjectUserInput").val("");
        $("#vProjectUserInput").attr("vaProjectUserId", "");
        $("#vProjectUserNumberInput").val("");
        $("#vAddSubjectBbz").val("0.00");
        $("#vAddSubjectScz").val("0.00");
        $("#vAddSubjectGsslrz").val("0.00");
        $("#vAddSubjectQyzc").val("0.00");
        $("#vAddSubjectSzpt").val("0.00");
        $("#vAddSubjectJj").val("");
        $("#addEditModal").modal("show");
    }

    //资金输入框聚焦和失去焦点事件，tag对象，type类型
    function _moneyInit(tag,type){

        if(type == 'focus'){
            //聚焦
            var tmpval = $(tag).val();

            if(tmpval == undefined || tmpval == '0' || tmpval == '0.00'){
                $(tag).val('');
            }

        }else{
            //失去焦点
            var tmpval = $(tag).val();

            if(tmpval == undefined || tmpval == ''){
                $(tag).val('0.00');
            }
        }

    }
    /**
     * 新增修改项目
     * @private
     */
    function _addEditSubject() {
        if(!_formValidate($("#addEditSubjectForm"))) {
            return;
        }

        var req = {};
        //有值为修改工程
        req.planProjId = $("#vAddProjectName").attr("vaAddProjectId");
        req.planProjName = $("#vAddProjectName").val();
//        req.parentImpleProjId = $("#vAddParentSubjectName").attr("vaParentSubjectId");
//        if(req.parentImpleProjId == "") {
//            req.parentImpleProjId = null;
//        }
        req.planProjClass = $("#vPlanTypeSelect2 option:selected").attr("vaPlanTypeId");
        req.impleProjId = $("#vAddSubjectName").attr("vaAddSubjectId");
        req.impleProjName = $("#vAddSubjectName").val();
//        req.developOrg = $("#vDevelopOrgNameInput2").attr("vaDevelopOrgId");
        req.developOrg = $("#vDevelopOrgNameInput2 option:selected").attr("value");
        //req.developOrgName = $("#vDevelopOrgNameInput2").attr("vaDevelopOrgId");
        req.statusCd = $("#vSubjectStateSelect option:selected").attr("value");
        req.startDt = _dateFormat($("#startDatepicker").val());
        req.endDt = _dateFormat($("#endDatepicker").val());
        req.linkman = $("#vProjectUserInput").attr("vaProjectUserId");
        req.linkmanTel = $("#vProjectUserNumberInput").val();
        req.contentScale = $("#vContentScale").val();
        req.impleSituation = $("#vImpleSituation").val();
        req.leadingPerson = $("#vProjectUserInput2").attr("vaProjectUserId");
        req.fundSourceBu = $("#vAddSubjectBbz").val();
        req.fundSourceSheng = $("#vAddSubjectScz").val();
        req.fundSourceGao = $("#vAddSubjectGsslrz").val();
        req.fundSourceQi = $("#vAddSubjectQyzc").val();
        req.fundSourceShi = $("#vAddSubjectSzpt").val();
        req.description = com.im.common.util.escapeTextArea($("#vAddSubjectJj").val());

        var url = null;
        var resultMsg = null;
        if(req.impleProjId == null || req.impleProjId == "") {
            url = "projectInfoService/addImpleProj";
            resultMsg = "新增工程项目成功";
        } else {
            url = "projectInfoService/updateImpleProj";
            resultMsg = "修改工程项目成功";
        }

        var resp = client.callAsJson(url, req);
        if (!resp.success) {
            toastr.error(resp.resultMsg);
            return;
        }
        toastr.success(resultMsg);
        _querySubjectLis(1);
        $("#addEditModal").modal("hide");
    }

    /**
     * 修改项目
     * @param object
     * @private
     */
    function _showEditSubject(index) {
        $('#addEditModal .modal-title').html('项目修改');
        var row = $('#vSubjectTable').datagrid('getData').rows[index];

        $("#vAddSubjectName").val(row.impleProjName);
        $("#vAddSubjectName").attr("vaAddSubjectId", row.impleProjId);
//        $("#vAddParentSubjectName").val("");
//        $("#vAddParentSubjectName").attr("vaParentSubjectId", row.parentImpleProjId);
        //$("#vPlanTypeSelect2").find("option:selected").removeAttr("selected");
        //$("#vPlanTypeSelect2").find("option").first().attr("selected", "selected");
        //$("#vPlanTypeSelect2").trigger("change");
        $("#vPlanTypeSelect2").val(row.planProjClass).trigger("change");
        $("#vDevelopOrgNameInput2").val(row.developOrg).trigger("change");
        $("#vAddProjectName").attr("vaAddProjectId", row.planProjId);
        $("#vAddProjectName").val(row.planProjId).trigger("change");
        $("#vSubjectStateSelect").val(row.statusCd).trigger("change");
        $("#startDatepicker").val(row.startDt);
        $("#endDatepicker").val(row.endDt);
        $("#vProjectUserInput2").val(row.leadingPersonName);
        $("#vProjectUserInput2").attr("vaProjectUserId", row.leadingPerson);
        $("#vProjectUserInput").val(row.linkmanName);
        $("#vProjectUserInput").attr("vaProjectUserId", row.linkman);
        $("#vProjectUserNumberInput").val(row.linkmanTel);
        $("#vAddSubjectBbz").val(row.fundSourceBu);
        $("#vAddSubjectScz").val(row.fundSourceSheng);
        $("#vAddSubjectGsslrz").val(row.fundSourceGao);
        $("#vAddSubjectQyzc").val(row.fundSourceQi);
        $("#vAddSubjectSzpt").val(row.fundSourceShi);
        $("#vContentScale").val(row.contentScale);
        $("#vImpleSituation").val(row.impleSituation);
        $("#vAddSubjectJj").val(com.im.common.util.descapeTextArea(row.description));

        if(row.preWorkSituation!=null && !row.preWorkSituation.trim()== ""){
            disableModalField(true);
        }
        $("#addEditModal").modal("show");
    }

    function disableModalField(flag){
        console.log(flag);
        if(flag){
            $('#vAddSubjectBbz').attr("disabled",true);
            $('#vAddSubjectScz').attr("disabled",true);
            $('#vAddSubjectGsslrz').attr("disabled",true);
            $('#vAddSubjectQyzc').attr("disabled",true);
            $('#vAddSubjectSzpt').attr("disabled",true);
        }else{
            $('#vAddSubjectBbz').attr("disabled",false);
            $('#vAddSubjectScz').attr("disabled",false);
            $('#vAddSubjectGsslrz').attr("disabled",false);
            $('#vAddSubjectQyzc').attr("disabled",false);
            $('#vAddSubjectSzpt').attr("disabled",false);
        }
    }

    /**
     * 新增子项目
     * @param object
     * @private
     */
    function _showAddSSubject(index) {
        $('#addEditModal .modal-title').html('新增子项目');
        var row = $('#vSubjectTable').datagrid('getData').rows[index];

        $("#vAddSubjectName").val("");
        $("#vAddSubjectName").attr("vaAddSubjectId", "");
//        $("#vAddParentSubjectName").val(row.impleProjName);
//        $("#vAddParentSubjectName").attr("vaParentSubjectId", row.impleProjId);
        //$("#vPlanTypeSelect2").find("option:selected").removeAttr("selected");
        //$("#vPlanTypeSelect2").find("option").first().attr("selected", "selected");
        //$("#vPlanTypeSelect2").trigger("change");
        $("#vAddProjectName").val(row.planProjName);
        $("#vAddProjectName").attr("vaAddProjectId", row.planProjId);
        $("#vPlanTypeSelect2").val(row.planProjClass).trigger("change");
        $("#vDevelopOrgNameInput2").val(row.developOrg).trigger("change");
        $("#vSubjectStateSelect").val(row.statusCd).trigger("change");
        $("#startDatepicker").val(row.startDt);
        $("#endDatepicker").val(row.endDt);
        $("#vProjectUserInput2").val(row.leadingPersonName);
        $("#vProjectUserInput2").attr("vaProjectUserId", row.leadingPerson);
        $("#vProjectUserInput").val(row.linkmanName);
        $("#vProjectUserInput").attr("vaProjectUserId", row.linkman);
        $("#vProjectUserNumberInput").val(row.linkmanTel);
        $("#vAddSubjectBbz").val(row.fundSourceBu);
        $("#vAddSubjectScz").val(row.fundSourceSheng);
        $("#vAddSubjectGsslrz").val(row.fundSourceGao);
        $("#vAddSubjectQyzc").val(row.fundSourceQi);
        $("#vAddSubjectSzpt").val(row.fundSourceShi);
        $("#vAddSubjectJj").val(com.im.common.util.descapeTextArea(row.impleSituation));
        $("#addEditModal").modal("show");
    }

    /**
     * 设置项目
     * @param object
     * @private
     */
    function _setSubject(index, source) {
        curSetRow = source;
        $("#projectSetModal").modal("show").attr('data-set',index);
    }
    function _showSetList(){
        var index = $("#projectSetModal").attr('data-set');
        var row = $('#vSubjectTable').datagrid('getData').rows[index];
        $("#projectSetModal .modal-title").text(row.impleProjName + "项目前期工作批复更新");
        var req = {};
        req.impleProjId = row.impleProjId;
        impleProjId = row.impleProjId;
        var resp = client.callAsJson("projectInfoService/queryImpleProjStageList", req);
        //var statusList = client.callAsJson("commonService/queryTabColParam", {tabName:'T_PROJECT_STAGE',colName:'STATUS_CD'}).result;
        var statusList = [
            {colVal:'20',colValName:'是'},
            {colVal:'30',colValName:'否'}
        ];
        if (resp.success) {
            var setcolumns=[[
                {field:'projStageId',title:"id",rowspan:2,resizable:true,fitColumns:true,hidden:true},
                {field:'projStateName',title:"前期工作阶段",rowspan:2,width:150,resizable:true,fitColumns:true},
                {field:'approvalInfo',title:"批复文号",rowspan:2,width:100,resizable:true,fitColumns:true,editor:'text'},
                {field:'replyDt',title:"批复时间",rowspan:2,width:80,resizable:true,fitColumns:true,
                    editor: {
                        type:'datebox',
                        options:{
                            parser:function(s){
                                var t = Date.parse(s);
                                if (!isNaN(t)){
                                    return new Date(t);
                                } else {
                                    return new Date();
                                }
                            },
                            formatter:function(date){
                                return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                            },
                        },
                    }
                },
                //{field:'dispOrder',title:"序号",width:50,resizable:true,fitColumns:true,editor:'text'},
                {field:'statusCd',title:"是否为<br/>当前阶段",rowspan:2,width:60,resizable:true,fitColumns:true,
                    formatter:function(value){
                        for(var i=0; i<statusList.length; i++){
                            if (statusList[i].colVal == value) return statusList[i].colValName;
                        }
                        return value;
                    },
                    editor:{
                        type:'combobox',
                        options:{
                            valueField:'colVal',
                            textField:'colValName',
                            data:statusList,
                            required:true
                        }
                    }},
//    		    {field:'statusName',title:"状态",width:80,resizable:true,fitColumns:true,
//    		    	formatter:function(value){
//						for(var i=0; i<statusList.length; i++){
//							if (statusList[i].colVal == value) return statusList[i].colValName;
//						}
//						return value;
//					},
//    		    	editor:{
//	                    type:'combobox',
//	                    options:{
//	                        valueField:'colVal',
//	                        textField:'colValName',
//	                        data:statusList,
//	                        required:true
//                    }
//                }},
                {title:"批复投资构成",colspan:6,fitColumns:true},
                //{field:'description',title:"进展描述",rowspan:2,width:150,resizable:true,fitColumns:true,editor:'text'},
                {field:'uploadName',title:"附件",rowspan:2,width:130,resizable:true,fitColumns:true,formatter: function(value,row,index){
                    if(value){
                        return value.replace(/;/g,'<br/>');
                    }else{
                        return '';
                    }
                }},
                {field:'file',title:"上传附件",rowspan:2,width:60,resizable:true,fitColumns:true,formatter: function(value,row,index){
                	if(row.projStageId && row.projStageId != ''){
                		return "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.uploadFile("+ index +",this,2);' title='上传附件'><i class='fa fa-upload'></i></a>";
                	}else{
                		return "<a href='javascript:;' style='display:none;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.uploadFile("+ index +",this,1);' title='上传附件'><i class='fa fa-upload'></i></a>";
                		
                	}
                }},
                {field:'option',title:"操作",rowspan:2,width:100,resizable:true,fitColumns:true,formatter: function(value,row,index){
                    if(row.statusCd != undefined){
                        if(row.statusCd == '20'){
                            return "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.setAdd(this,1);' title='修改'><i class='fa fa-edit'></i></a>"+
                                '<a href="javascript:; "onclick="com.im.projectInfoManage.carrayProjectManage.invoke.saveSetData('+index+',this,1)" title="保存" style="display:none;"><i class="fa fa-check-square-o"></i></a>'+
                                '<a href="javascript:; "onclick="com.im.projectInfoManage.carrayProjectManage.invoke.canceSetlList(this,1)" title="取消" style="display:none;"><i class="fa fa-refresh"></i></a>'+
                                "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.setRemove("+ index +");' title='删除'><i class='fa fa-trash'></i></a>";
                        }
                    }else{
                        return "<a href='javascript:;' onclick='com.im.projectInfoManage.carrayProjectManage.invoke.setAdd(this,2);' title='新增'><i class='fa fa-plus'></i></a>"+
                            '<a href="javascript:; "onclick="com.im.projectInfoManage.carrayProjectManage.invoke.saveSetData('+index+',this,2)" title="保存" style="display:none;"><i class="fa fa-check-square-o"></i></a>'+
                            '<a href="javascript:; "onclick="com.im.projectInfoManage.carrayProjectManage.invoke.canceSetlList(this,2)" title="取消" style="display:none;"><i class="fa fa-refresh"></i></a>';
                    }
                }}
            ],
                [   {field:'total',title:"合计",fitColumns:true},
                    {field:'fundSourceBu',title:"部补助",fitColumns:true,editor:{type:'numberbox',options:{precision:2}}},
                    {field:'fundSourceSheng',title:"省财政",fitColumns:true,editor:{type:'numberbox',options:{precision:2}}},
                    {field:'fundSourceGao',title:"政府融资",fitColumns:true,editor:{type:'numberbox',options:{precision:2}}},
                    {field:'fundSourceShi',title:"市州配套",fitColumns:true,editor:{type:'numberbox',options:{precision:2}}},
                    {field:'fundSourceQi',title:"企业自筹",fitColumns:true,editor:{type:'numberbox',options:{precision:2}}}]
            ];
            $('#setTable').datagrid({
                checkOnSelect:true,
                nowrap:false,
                fitColumns:true,
                columns:setcolumns,
                loadMsg:'数据加载中，请耐心等待',
                data:resp.result,
//        	    onBeginEdit : function(rowIndex, rowData){
//        	    	var editors = $('#setTable').datagrid('getEditors', rowIndex);
//        	    	var lendEditor = editors[0];
//        	    	console.log(1);
//        	    }
            });
            var attr1 = $(curSetRow).parents('tr').find('td[field="projStageClassName"]');
            for(var i=resp.result.rows.length -1; i>=0; i--){
                if(resp.result.rows[i].statusCd != null) {
                    $(attr1).text(resp.result.rows[i].projStateName);
                    break;
                }
            }

        }else{
            toastr.error(resp.resultMsg);
            return;
        }
    }
    function _uploadFile(index,target,type){
        rowTarget =  target;
        curIndex=index;
        fileInfo = {};
        $('#uploadFileModal').modal("show").attr('value',type);
        var file = new com.im.common.file();
        tmpfiles = file.activate(1);
        $('#common_file').val('');
        $('#common_file_name').hide();
        //调整样式
        $("#common_file_src").css({"margin-left":"26.6%", "margin-right":"26.6%"});
        $("#upFile").before($("#common_file_src"));
    }
    function _initFile() {

        client.callAsFile(tmpfiles.newly, function(result) {
            if(result.success){
                fileInfo = result.result;
                toastr.success('文件上传成功！');
                var data=$("#setTable").datagrid('getData').rows[curIndex];
                //如果是编辑就直接保存
                if($('#uploadFileModal').attr('value') == '2'){
                	var fileList = [];
                    $.each(fileInfo, function(index, item){
                        var file = {
                            "uploadName":item.attachFullName,
                            "filePath":item.attachPath,
                            "fileSuffix":item.attachSuffix,
                            "uploadSize":item.attachSize
                        };
                        fileList.push(file);
                    });
                	var saveparam={
                        fileList:fileList,
                        projStageId: data.projStageId
                    };
                    var result = client.callAsJson("projectInfoService/uploadProjStageFile", saveparam);
                    if(result.resultCode=='0'){
                        toastr.success("保存成功");
                    }else {
                        toastr.error("保存失败");
                    }
                }
                
                var fileNames="";
                for(var i=0;i<fileInfo.length;i++){
                    if(i==fileInfo.length){
                        fileNames+=fileInfo[i].attachFullName;
                    }else{
                        fileNames+=fileInfo[i].attachFullName+",";
                    }
                }

                if(data.uploadName!=null && data.uploadName!=''){
                    data.uploadName+=','+fileNames;
                }else{
                    data.uploadName=fileNames;
                }
                $(rowTarget).parents('tr').find('td[field="fundSourceBu"] input').val()
                //
                var fundSourceBu = $(rowTarget).parents('tr').find('td[field="fundSourceBu"] input').val()
                data.fundSourceBu = fundSourceBu;
                //$(rowTarget).parents('tr').find('td[field="uploadName"]').val(fileNames);
                $(rowTarget).parents('tr').find('td[field="uploadName"]').html(fileNames);

                // $('#setTable').datagrid('updateRow',{
                // 	index: curIndex,
                // 	row: JSON.parse(JSON.stringify(data))
                //     //row : {uploadName: fileNames}
                // });

            }else{
                toastr.error('文件上传失败！');
            }
        });
    }
    /**
     * 设置新增
     * @param object
     * @private
     */
    function _getRowIndex(target){
        var tr = $(target).closest('tr.datagrid-row');
        return parseInt(tr.attr('datagrid-row-index'));
    }
    function _setAdd(target,type){
        rowTarget =  target;
        $('#setTable').datagrid('beginEdit', _getRowIndex(target));
        $(target).hide().next().show();
        $(target).next().next().show();
        if(type == '2'){
            $(target).parents('tr').find('td[field="file"] a').show();
        }
        //设置各默认值为0.00
       $(target).parents('tr').find('td[field="total"] input').val('0.00');
       $(target).parents('tr').find('td[field="fundSourceBu"] input').val('0.00');
       $(target).parents('tr').find('td[field="fundSourceSheng"] input').val('0.00');
       $(target).parents('tr').find('td[field="fundSourceGao"] input').val('0.00');
       $(target).parents('tr').find('td[field="fundSourceShi"] input').val('0.00');
       $(target).parents('tr').find('td[field="fundSourceQi"] input').val('0.00');
   	    $('td[field="replyDt"] .datagrid-editable-input').datepicker();
    }
    function _saveSetData(index,target,type){
        var obj = $('#projectSetModal .datagrid-body table tbody tr:eq('+index+')');
        var approvalInfoObj = obj.find('td[field="approvalInfo"] .datagrid-editable-input').val();
        var replyDtObj = obj.find('td[field="replyDt"] .textbox-text').val();
        var statusCdObj = obj.find('td[field="statusCd"] .textbox-text').val();
        if(approvalInfoObj == ''){
        	toastr.error('批复文号必填');
        	return false;
        }
        if(replyDtObj == ''){
        	toastr.error('批复时间必选');
        	return false;
        }
        if(statusCdObj == ''){
        	toastr.error('是否为当前阶段必选');
        	return false;
        }
        com.im.common.confirm("确定要保存吗？", null, function () {
            $('#setTable').datagrid('endEdit', _getRowIndex(target));
            $(target).hide().prev().show();
            $(target).next().hide();
            var setList = $('#setTable').datagrid('getData').rows[index];
            var statusCd;
            var statusList = [
                {colVal:'20',colValName:'是'},
                {colVal:'30',colValName:'否'}
            ];
            $.each(statusList, function(index, item){
                if(item.colValName == setList.statusCd || item.colVal == setList.statusCd){
                    statusCd = item.colVal;
                }
            });
            var fileList = [];
            $.each(fileInfo, function(index, item){
                var file = {
                    "uploadName":item.attachFullName,
                    "filePath":item.attachPath,
                    "fileSuffix":item.attachSuffix,
                    "uploadSize":item.attachSize
                };
                fileList.push(file);
            });
            var saveparam={
                impleProjId : impleProjId,
                projStageClass:setList.projStageClass,
                dispOrder : setList.dispOrder,
                statusCd : statusCd,
                description : setList.description,
                projStageId: setList.projStageId,
                approvalInfo:setList.approvalInfo,
                replyDt:setList.replyDt,
                fundSourceBu:setList.fundSourceBu,
                fundSourceSheng:setList.fundSourceSheng,
                fundSourceGao:setList.fundSourceGao,
                fundSourceShi:setList.fundSourceShi,
                fundSourceQi:setList.fundSourceQi
            };
            if(type == 2){
            	saveparam.fileList = fileList;
                var result = client.callAsJson("projectInfoService/addProjStage", saveparam);
            }else{
            	saveparam.fileList = [];
                var result = client.callAsJson("projectInfoService/updateProjStage", saveparam);
            }
            if(result.resultCode=='0'){
                //下面的方式会导致表格错位。。。。
                //$('#vSubjectTable').datagrid('getEditor',{'index':setParentIndex,'field':'projStageClassName'}).target.val(setList.projStateName);
                //$('#vSubjectTable').datagrid('endEdit', setParentIndex);
                //$('#vSubjectTable').datagrid('updateRow',{index:setParentIndex,row:{projStageClassName:setList.projStateName}});
                //$('#vSubjectTable').datagrid('refreshRow', setParentIndex);
                var attr1 = $(curSetRow).parents('tr').find('td[field="projStageClassName"]');
                $(attr1).text(setList.projStateName);

                toastr.success("保存成功");
                freshFlag =  true;
                _showSetList();
            }else {
                toastr.error(result.result.message);
                _showSetList();
            }
        });
    }
    function _canceSetlList(target,type){
        $('#setTable').datagrid('cancelEdit', _getRowIndex(target));
        if(type=='2'){
            $(target).parents('tr').find('td[field="file"] a').show();
        }
    }
    /**
     * 设置删除
     * @param object
     * @private
     */
    function _setRemove(index){
        com.im.common.confirm("确定要删除吗？", null, function () {
            var setRemoveList = $('#setTable').datagrid('getData').rows[index];
            var param = {};
            param.projStageId = setRemoveList.projStageId;
            param.impleProjId = setRemoveList.impleProjId;
            param.projStageClass = setRemoveList.projStageClass;
            var result = client.callAsJson("projectInfoService/deleteProjStage",param);
            if(result.resultCode=='0'){
                toastr.success("删除成功");
                freshFlag =  true;
                _showSetList();
            }else {
                toastr.error('请稍后再试！'+result.resultMsg);
            }
        });
    }
    /**
     * 删除项目
     * @param object
     * @private
     */
    function _deleteSubject() {
        var impleProjIds = new Array();
        $.each($('#vSubjectTable').datagrid('getChecked'), function(index, item){
            impleProjIds.push(item.impleProjId);
        });
        if(impleProjIds.length == 0){
            toastr.error('请选择需要删除的项目');
            return;
        }
        com.im.common.confirm("确认是否删除项目", null, function () {
            var req = {};
            req.impleProjIds = impleProjIds.join(',');
            var resp = client.callAsJson("projectInfoService/deleteImpleProj", req);
            if (!resp.success) {
                toastr.error(resp.resultMsg);
                return;
            }
            toastr.success("删除工程项目成功");
            _querySubjectLis(1);
        })
    }

    /**
     * 项目简介
     * @param object
     * @private
     */
    function _showSubjectContent(impleProjName,contentScale) {
        // var row = $('#vSubjectTable').datagrid('getData').rows[index];
        // var req= {};
        // req.impleProjId = row.impleProjId;
        // var resp = client.callAsJson("projectInfoService/queryImpleProjDetail", req);
        // if (!resp.success) {
        //     toastr.error(result.resultMsg);
        //     return;
        // }

        $("#vSubjectName").text("【"+impleProjName+"】----建设内容");
        //$("#vSubjectContent").html(resp.result.impleSituation);
        $("#vSubjectContent").html(contentScale);
        $("#projectContentModal").modal("show");
    }

    /**
     * 条件重置
     * @private
     */
    function _resetCond() {
        $("#vDevelopOrgInput2").val("").trigger("change");
        $("#vPlanTypeSelect").find("option:selected").removeAttr("selected");
        $("#vPlanTypeSelect").find("option").first().attr("selected", "selected");
        $("#vPlanTypeSelect").trigger("change");
        $("#vProjectNameInput").val("");
        $("#vSubjectNameInput").val("");
        _querySubjectLis(1);//重复调用
    }

    function _dateFormat(date) {
        var date = new Date(date);
        return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
    }
    //导出表格
    function _exportList(){
        var param = {
            "classes": "ProjectInfoService",
            "fileName": "实施项目列表",
            "method": "queryImpleProjList",
            "title": {
                "impleProjName":"实施项目名称",
                "planProjName":"工程名称",
                "developOrgName": "建设单位",
                "startDt": "开工年$建设年限",
                "endDt": "完工年$建设年限",
                "leadingPersonName": "项目负责人",
                "linkmanName": "项目联系人",
                "contentScale": "主要建设内容",
                "projStageClassName": "当前阶段",
                "impleSituation": "进展描述",
                "total": "合计$阶段资金构成（单位：万元）",
                "fundSourceBu": "部补助$阶段资金构成（单位：万元）",
                "fundSourceSheng": "省财政$阶段资金构成（单位：万元）",
                "fundSourceGao": "政府融资$阶段资金构成（单位：万元）",
                "fundSourceShi": "市州配套$阶段资金构成（单位：万元）",
                "fundSourceQi": "企业自筹$阶段资金构成（单位：万元）",
                "statusName": "状态"
            }
        };
        param.param={};
        param.param.impleProjName = $("#vSubjectNameInput").val();
        param.param.planProjName = $("#vProjectNameInput").val();
        param.param.planProjClass = $("#vPlanTypeSelect option:selected").attr("value");
        param.param.developOrg = $("#vDevelopOrgInput2 option:selected").attr("value");
        var url='/InfoManageWeb/commonService/export?json='+encodeURI(JSON.stringify(param));
        window.open(url, '_blank');
    }

    return {
        init : _init,
        showSSubject : _showSSubject,
        showEditSubject : _showEditSubject,
        showAddSSubject : _showAddSSubject,
        setSubject : _setSubject,
        deleteSubject : _deleteSubject,
        showSubjectContent : _showSubjectContent,
        uploadFile:_uploadFile,
        setAdd:_setAdd,
        saveSetData:_saveSetData,
        canceSetlList:_canceSetlList,
        setRemove:_setRemove
    }
}();